package com.FFF;

public class ATM {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        double banlance = 0;

        while (true) {
            System.out.println("======ATM======");
            System.out.println("1.存款");
            System.out.println("2.取款");
            System.out.println("3.显示余额");
            System.out.println("4.退出");
            System.out.println("请选择（1-4）：");

            int res = scn.nextInt();
            System.out.println("你选择的是----》" + res);

            if (res == 1) {
                System.out.println("请输入存款金额");
                double price = scn.nextDouble();
                banlance = banlance + price;
                if (banlance < 0) {
                    System.out.println("存款金额不合法");
                }
            } else if (res == 2) {
                System.out.println("请输入取款金额");
                double price2 = scn.nextDouble();
                banlance = banlance - price2;

                if (price2 > banlance) {
                    System.out.println("当前余额为：" + banlance + ">余额不足");

                } else if (price2 < 0) {
                    System.out.println("取款金额不合法");
                } else {
                    banlance = banlance - price2;
                }
            } else if (res == 3) {
                System.out.println("当前余额为：" + banlance);
            } else if (res == 4) {

                break;
            }




        }
    }
}
